package com.nulldev.util.threading.v3;

import com.nulldev.util.math.MathUtil;

public class RunnableWorker {

	public static Worker fromRunnable(final Runnable r) {
		return fromRunnable(r, "$Runnable.Worker." + MathUtil.randLong(0, 1000000L));
	}
	
	public static Worker fromRunnable(final Runnable r, final String id) {
		return new Worker() {
			
			@Override
			public String getName() {
				return id;
			}
			
			@Override
			public void execute() {
				r.run();
			}
		};
	}
}
